package com.tanhua.manage.vo;

import cn.hutool.core.date.DateTime;

import com.tanhua.manage.pojo.RoleOpreation;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;

import java.util.List;

/**
 * @author 杨一帆
 * @date 2020/12/13  11:53
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RoleOperationVo {

    private Integer id;//主键自增
    private String role;//管理员姓名
    private String ip; //管理员操作电脑IP
    private DateTime creatTime; //管理员操作时间
    private String opreation; //管理员操作
    private String describes;//操作描述

    private Long userId; // 被操作用户Id


    public static final RoleOperationVo format(RoleOpreation roleOpreation) {
        RoleOperationVo roleOperationVo = new RoleOperationVo();
        roleOperationVo.setCreatTime(new DateTime(roleOpreation.getCreatTime()));
        roleOperationVo.setRole(roleOpreation.getRole());
        roleOperationVo.setDescribes(roleOpreation.getDescribes());
        roleOperationVo.setId(roleOpreation.getId());
        roleOperationVo.setIp(roleOpreation.getIp());
        roleOperationVo.setOpreation(roleOpreation.getOpreation());
        roleOperationVo.setUserId(roleOpreation.getUserId());
        return roleOperationVo;
    }

    public static final List<RoleOperationVo> formatToList(List<RoleOpreation> roleOpreations) {
        List<RoleOperationVo> list = new ArrayList<>();
        for (RoleOpreation roleOpreation : roleOpreations) {
            list.add(format(roleOpreation));
        }
        return list;
    }
}
